package com.ujiuye.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/rd1")
public class RequestDemo1 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String scheme = req.getScheme();
        System.out.println("协议"+scheme);
        String serverName = req.getServerName();
        System.out.println("服务名称"+serverName);
        int serverPort = req.getServerPort();
        System.out.println("端口号"+serverPort);
        String contextPath = req.getContextPath();
        System.out.println("项目名称"+contextPath);
        String method = req.getMethod();
        System.out.println("请求方式"+method);
        String queryString = req.getQueryString();
        System.out.println("获取查询参数"+queryString);
        String requestURI = req.getRequestURI();
        System.out.println("不包含协议和端口" +requestURI);
        StringBuffer requestURL = req.getRequestURL();
        System.out.println("包含协议和端口"+requestURL);

    }
}
